home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / ste / autoexec.lzh / SOURCE / PLAYER.S < prev    next >
Text File  |  1991-08-05  |  8KB  |  237 lines

  1.  
  2. EXPORT STe_segment, STe_module, STe_end
  3. EXPORT SetFilter, SetPlayFreq
  4.  
  5. EXPORT DMAinterupt
  6. EXPORT PlayRoutine
  7.  
  8. include "nt_const.s"
  9.  
  10.  
  11. ******************* ROUINE TO STOP THE SOUND DMA ********************
  12. STe_end:        pea     Stop_DMA(PC)
  13.                 tst.w   d0
  14.                 beq.b   hard_stop
  15.                 move.l  #Stop_DMA_soft,(a7)
  16. hard_stop:      move.w  #Supexec,-(SP)
  17.                 trap    #Xbios
  18.                 addq.w  #6,SP        ;remove params to 'super'
  19.                 rts
  20.  
  21.                 
  22. Stop_DMA:       lea     MFP,A0
  23.                 move.b  (A0)+,MFP_EnblA
  24.                 move.b  (A0)+,MFP_MaskA
  25.                 move.w  #0,PCM_CONTROL ;Stop DMA sound chip
  26.                 move.l  #PCM_VECTOR,D0
  27.                 lea     DMAinterupt-12(PC),A0
  28.                 bra     XB_kill
  29.  
  30.  
  31. Stop_DMA_soft:  lea     MFP,A0
  32.                 move.b  (A0)+,MFP_EnblA
  33.                 move.b  (A0)+,MFP_MaskA
  34.                 bsr     no_reload
  35.                 move.l  #PCM_VECTOR,D0
  36.                 lea     DMAinterupt-12(PC),A0
  37.                 bra     XB_kill
  38.  
  39. ******************* ROUINE TO START THE SOUND DMA *******************
  40. **************************** PLAY SEGMENT ***************************
  41. STe_segment:    move.l  A0,tablePointer ; char **samples
  42.                 ext.l   D0
  43.                 addq.l  #1,D0           ; int repeat
  44.                 beq.b   dontrepeat
  45.                 subq.l  #1,D0
  46.                 lsl.l   #2,D0
  47.                 add.l   A0,D0
  48. dontrepeat:     move.l  D0,inittable    ; zero if no rep., else addr.                DATA
  49.                 pea     Start_DMA
  50.                 move.w  #Supexec,-(SP)
  51.                 trap    #Xbios
  52.                 addq.w  #6,SP        ;remove params to 'super'
  53.                 rts
  54.  
  55.  
  56.            
  57. Start_DMA:      lea     MFP,A0
  58.                 move.b  MFP_EnblA,(A0)+
  59.                 move.b  MFP_MaskA,(A0)+
  60.  
  61.                 clr.w  PCM_CONTROL ;Stop DMA sound chip
  62.  
  63.                 move.b  MFP_Data,D0   ;Read monitor-type (mono/color)
  64.                 eor.b   D0,MFP_Edge   ;Enable IRQ on Sound _not_ Active!
  65.                 andi.b  #%1111111,MFP_Edge ; Sound not Active.
  66.                 eor.b   D0,MFP_Edge   ; IRQ when sound becomes not active.
  67.  
  68.                 lea     DMAinterupt-4(PC),A0
  69.                 move.l  PCM_VECTOR,(A0)+
  70.                 move.l  A0,PCM_VECTOR
  71.  
  72.                 bclr    #7,MFP_PendA
  73.                 bset    #7,MFP_MaskA  ;Mask 'Sound Active' interupt.
  74.                 bset    #7,MFP_EnblA  ;Enable 'Sound Active' interupt
  75.  
  76.                 bsr     DMAmusic
  77.                 moveq   #3,D0
  78.                 and.w   PCM_CONTROL,D0
  79.                 bne.b   last_segment
  80.                 
  81.                 move.w  #3,PCM_CONTROL ;start DMA chip in LOOP mode
  82.                 bsr     DMAmusic
  83.                 
  84. last_segment:   rts
  85.  
  86.  
  87. ************** ROUINE TO SET THE FILTER BEFORE PLAYING **************
  88. ****************************     oOo     ****************************
  89. MIX_GI_12dB     EQU %10_000_0000_00
  90. SetFilter:      pea    StuffInMW
  91.                 move.w  #Supexec,-(SP)
  92.                 trap    #Xbios
  93.                 addq.w  #6,SP        ;remove params to 'super'
  94.                 rts
  95. StuffInMW:      move.w #MIX_GI_12dB,MW_DATA
  96.                 move.w #%111_1111_1111,MW_MASK
  97.                 rts
  98.                 
  99.                 
  100. **************** ROUINE TO SET THE PLAYING FREQUENCY ****************
  101. ****************************     oOo     ****************************
  102. SetPlayFreq:    move.w d0,PlayFreq ; move argument to global var.
  103.                 pea    setfreq
  104.                 move.w  #Supexec,-(SP)
  105.                 trap    #Xbios
  106.                 addq.w  #6,SP        ;remove params to 'super'
  107.                 rts
  108. setfreq:        move.w  PlayFreq,PCM_MODE
  109.                 rts
  110.                 
  111.                 
  112. ****************************************************************
  113. * Routine to play the music, called when sound buffer is empty *
  114. ****************************************************************
  115.                 SUPER
  116.                 
  117. ***************** RUTINES FOR THE STE DMA SOUND *****************
  118.                 DC.L    'XBRA','zexc'
  119.                 DS.L    1                ; Old Vector
  120. DMAinterupt:    movem.l D0/A0-A1,-(SP)
  121.                 
  122.                 bclr    #7,MFP_ISRA
  123.                 move.w  #$2300,SR
  124.                 
  125.                 bsr.b   DMAmusic
  126.                 
  127.                 movem.l (SP)+,D0/A0-A1
  128.                 rte
  129.  
  130.  
  131. DMAmusic:       bsr.b Segment
  132.                 
  133.                 ; This Routine returns D0: DMA_START, A0: DMA_END
  134.                 
  135.                 beq.b   no_reloadDMA
  136.                 lea     PCM_START,A1  ;Insert Secondary-buffer in the queue.
  137.                 movep.w D0,3(A1)
  138.                 swap    D0
  139.                 move.w  D0,(A1)
  140.  
  141.                 move.l  A0,D0
  142.                 movep.w D0,3+PCM_END-PCM_START(A1)
  143.                 swap    D0
  144.                 move.w  D0,PCM_END-PCM_START(A1)
  145. no_reloadDMA:   rts
  146.  
  147.  
  148. ******************** ROUTINE TO PLAY SEGM FILES ********************
  149. *** Uses : D0,A0,A1
  150. Segment:        movea.l tablePointer,A0
  151.                 cmpi.l  #-1,(A0)
  152.                 bne.b   no_repeat
  153.                 move.l  inittable,D0
  154.                 movea.l D0,A0
  155.                 beq.b   no_reload 
  156. no_repeat:      movea.l (A0)+,A1
  157.                 move.l  (A0)+,D0
  158.                 move.l  A0,tablePointer
  159.                 lea     0(A1,D0.l),A0 ;end of DMA
  160.                 move.l  A1,D0; start of DMA
  161.                 rts
  162.  
  163. no_reload:      ; If the DMA chip isn't in LOOP mode, don't do anything
  164.                 moveq   #3,D0
  165.                 and.w   PCM_CONTROL,D0
  166.                 subq.w  #3,D0
  167.                 bne.b   dont_set
  168.                 ; At this point is the last segment playing - therefor
  169.                 ; set the DMA chip into SINGLE, rather than LOOP
  170.                 ; playback mode... The DMA chip will then stop after
  171.                 ; the sample have been played!
  172.                 move.w  #1,PCM_CONTROL ; DMA chip in SINGLE mode
  173. dont_set:       moveq   #0,D0
  174.                 rts
  175.  
  176.  
  177. **************** XB_SEARCH *********************
  178. ** entry: A0:Pointer to 'Magic', D0:vector.    *
  179. ** returns : if found -> ZERO
  180. xb_search:                  
  181.     MOVE.L D0, A1           ;A1 now points to 'vector'
  182.     MOVE.L A0, D2           ;D2 contains copy of pointer to 'magic' 
  183. xb_next:
  184.     MOVE.L A1, D1           ;At end D1 points to old 'next' pointer
  185.     MOVE.L (A1), A1         ;Find next XBRA struct.
  186.     LEA    -12(A1), A1
  187.     MOVE.L D2, A0           ;Copy pointer to magic into A0 
  188.     CMP.L (A0)+, (A1)+      ;Is 'XBRA' ok ?
  189.     BNE.B not_xbra
  190.     CMP.L (A0)+, (A1)+      ;Is ID ok ?
  191.     BNE.B xb_next           ;Try next in chain...
  192. not_xbra:
  193.     RTS
  194.  
  195.  
  196.  
  197. ********************************************************************
  198. * Routine 'XB_kill'  (the -9 option!)
  199. * Note !
  200. *   This routine depends on the fact that 'Magic' contains the 
  201. *   'Oldvec' field. It uses this to unchain all the routines after
  202. *   the last XBRA routine til your routine.
  203. *
  204. * entry: (vector, Pointer to 'Magic').
  205. *
  206. * exit  : 
  207. *    D0 : Retval (1=was in chain - OK [-but removed, not killed]).
  208. * uses:
  209. *   D0-D2/A0-A1 ; D2 is only used by xb_search
  210. ********************************************************************
  211. XB_kill:
  212.     BSR.B xb_search            ;Get last XBRA routine in chain.            
  213.     BZE.B xb_rem                ;If the routine was found - dispose normally
  214.                                     ;A0+4 is our pointer to next in chain. 
  215.     MOVE.L D1, A1                ;D1 is the Last XBRA pointer to next routine
  216.     MOVE.L 4(A0), (A1)        ;Make previous XBRA point on later routine.
  217.     RTS
  218. xb_rem:                            ;(A1)->XBRA.xb_oldvec of later routine.
  219.     MOVE.L D1, A0                ;D1->XBRA.xb_oldvec of routine before our.
  220.     MOVE.L (A1), (A0)            ;Make previous routine point on later one.
  221.     RTS
  222.     
  223.     
  224.                 .BSS
  225.                 .EVEN
  226. _vars:                
  227. tablePointer:   DS.L 1
  228. inittable:      DS.L 1
  229. PlayBuff:       DS.L 1
  230. PlayRoutine:    DS.L 1
  231.  
  232. PlayFreq:       DS.W 1
  233.  
  234. MFP:            DS.B 2
  235.  
  236.                 
  237.